//
//  vdEventReceiver.h
//  Void Dead
//
//  Created by Sidney Just on 27.11.09.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#import <Foundation/Foundation.h>
#import "vdEventHandler.h"

@protocol vdEventProtocol;

/**
 * This class notifies you when a specified event type gets fired.
 **/
@interface vdEventReceiver : NSObject {
	//\cond
	vdEventType listenTo;
	vdEventMessage *lastEvent;
	
	id delegate;
	//\endcond
}

/**
 * The event types that will be received by the vdEventReceiver (by default this is vdNone)
 **/
@property vdEventType listenTo;

/**
 * The last event 
 @remark (this is only available after vdEventFired: gets called!!!)
 **/
@property vdEventMessage *lastEvent;

/**
 * The delegate that receives the event notifications (must implement the vdEventProtocol protocol)
 **/
@property (assign) id delegate;

/**
 * Returns a new vdEventReceiver
 @param aDelegate The delegate that retrieves the notification for new events (must implement the vdEventProtocol protocol)
 @param aType The type of events you want to receive. You can add more than one event by using a bitmask.
 @return The pointer to the new eventReceiver
 **/
+ (vdEventReceiver *)receiverWithDelegate:(id)aDelegate andType:(vdEventType)aType;

/**
 * Returns a new vdEventReceiver
 @return The pointer to the new eventReceiver
 **/
+ (vdEventReceiver *)receiver;

@end

/**
 * The vdEventProtocol. Must be implemented if you want to use vdEventReceiver.
 **/
@protocol vdEventProtocol
@optional
/**
 * This optional function gets called when the vdEventReceiver receives an event.
 @param sender The receiver thats got the event.
 **/
- (void)vdEventFired:(vdEventReceiver *)sender;

@end

